package com.zut.serviceImpl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zut.mapper.UserMapper;
import com.zut.pojo.User;
import com.zut.service.UserService;

@Service("userService")  //使用注解配置实例对象的名称
@Transactional
public class UserServiceImpl implements UserService{
	//调用数据层mapper
	@Autowired
	private UserMapper userMapper;

	@Override
	public User findUserById(int id) {
		User user = userMapper.findUserById(id);
		return user;
	}
	
	@Override
	public List<User> findUserByIds(ArrayList<Integer> ids) {
		return userMapper.findUserByIds(ids);
	}
	

	@Override
	public List<User> findUserByName(User user) {
		List<User> list = userMapper.findUserByName(user);
		return list;
	}

	@Override
	public List<User> findUserAll(int pageNum, int pageSize) {
		//参数pageNum 是页码值   参数pageSize 代表是每页显示条数
		PageHelper.startPage(pageNum,pageSize);
		return userMapper.findUserAll();
	}

	@Override
	public int updateUserById(User user) {
		return userMapper.updateUserById(user);
	}

	@Override
	public int insertUser(User user) {
		return userMapper.insertUser(user);
	}

	
}
